<?php
namespace Lib;
class View {

    /**
     * @param array $data
     * @param string $tplFile
     * @throws \Exception
     */
    public static function display(array $data = array(), $tplFile = '') {
        $tplPath = Config::getRootPath() . DIRECTORY_SEPARATOR . 'Template' . DIRECTORY_SEPARATOR;
        $fileName = realpath($tplPath . $tplFile . '.php');
        if ($fileName === false) {
            throw new \Exception("no file {$tplFile}", 404);
        }else{
            if (!empty($data)) {
                \extract($data);
            }
            include $fileName;
        }
    }
}